package csu.web.dining.web.servlet;

import csu.web.dining.domain.Item;
import csu.web.dining.domain.Order;
import csu.web.dining.domain.Product;
import csu.web.dining.service.CatalogService;
import csu.web.dining.service.OrderService;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;

import java.io.IOException;
import java.util.List;

public class ViewOrderFormServlet extends HttpServlet{
    //要跳转的页面
    private static final String VIEW_ORDER_FORM = "/WEB-INF/jsp/order/viewOrder.jsp";

    private OrderService orderService ;

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        int orderId =Integer.parseInt(req.getParameter("orderId"));
        orderService=new OrderService();
        Order order=orderService.getOrder(orderId);
        HttpSession session = req.getSession();
        session.setAttribute("order", order);
        req.getRequestDispatcher(VIEW_ORDER_FORM).forward(req, resp);
    }

}
